﻿using System;

namespace Person
{
    public class Person
    {
        string firstName;
        string lastName;
        string gender;
        string birthDate;

        public Person(string firstName, string lastName, string gender, string birthDate)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.gender = gender;
            this.birthDate = birthDate;
            this.FirstNameChanged += new EventHandler(OnFirstNameChanged);
            this.LastNameChanged += new EventHandler(OnLastNameChanged);
            this.GenderChanged += new EventHandler(OnGenderChanged);
            this.BirthDateChanged += new EventHandler(OnBirthDateChanged);
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                if (value != firstName)
                {
                    firstName = value;
                    FirstNameChanged(this, EventArgs.Empty);
                }
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                if (value != lastName)
                {
                    lastName = value;
                    LastNameChanged(this, EventArgs.Empty);
                }
            }
        }

        public string Gender
        {
            get
            {
                return gender;
            }
            set
            {
                if (value != gender)
                {
                    gender = value;
                    GenderChanged(this, EventArgs.Empty);
                }
            }
        }

        public string BirthDate
        {
            get
            {
                return birthDate;
            }
            set
            {
                if (value != birthDate)
                {
                    birthDate = value;
                    BirthDateChanged(this, EventArgs.Empty);
                }
            }
        }

        public event EventHandler FirstNameChanged;

        protected void OnFirstNameChanged(object sender, EventArgs args)
        {
            Console.WriteLine("First name changed!");
        }

        public event EventHandler LastNameChanged;

        protected void OnLastNameChanged(object sender, EventArgs args)
        {
            Console.WriteLine("Last name changed!");
        }

        public event EventHandler GenderChanged;

        protected void OnGenderChanged(object sender, EventArgs args)
        {
            Console.WriteLine("Gender changed!");
        }

        public event EventHandler BirthDateChanged;

        protected void OnBirthDateChanged(object sender, EventArgs args)
        {
            Console.WriteLine("Birth date changed!");
        }
    }
}
